<?php

namespace app\model\admin;

use app\model\company\Company;
use crmeb\basic\BaseModel;
use think\model\Relation;

// 题库
class QuestionModel extends BaseModel
{
    protected $key = 'id';
    protected $table = 'sj_topic';

    protected $json = [
        'answer'
    ];
    protected $jsonAssoc = true;
    protected $autoWriteTimestamp = true;

    public function trainType(): Relation
    {
        return $this->belongsToMany(TrainTypeModel::class, 'sj_question_train_type');
    }

    public function company(): Relation
    {
        return $this->belongsTo(Company::class, 'company_id', 'id');
    }
}